<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>鼠标事件</title>
    <style>
        .container{
            width: 400px;
            height: 300px;
            background: #aef;
            margin: 0 auto;
        }
    </style>
</head>
<body>
    <div id="root"> </div>

    <script src="../js/react.development.js"></script>
    <script src="../js/react-dom.development.js"></script>
    <script src="../js/babel.min.js"></script>
    <script src="https://cdn.bootcdn.net/ajax/libs/lodash.js/4.17.21/lodash.js"></script>

    <script type="text/babel">

        class App extends React.Component{
            render(){
                return <div className="container">
                        <a href="http://www.atguigu.com" onClick={this.jump}>尚硅谷</a>
                        <form action="http://www.baidu.com" onSubmit={this.submit}>
                            <input onKeyDown={this.handleKeyDown} type="text" name="username" />
                            <input type="submit" value="登录" />   
                            abcdefghijklmnopqrstuvwxyz 
                        </form>
                    </div>
            }

            //声明回调
            jump = (e) => {
                //阻止默认行为
                e.preventDefault();
            }

            submit = (e) => {
                console.log(123);
                e.preventDefault();
            }

            handleKeyDown = (e) => {
                console.log(456);
                e.preventDefault();
            }
        }

        ReactDOM.render(<App />, document.querySelector("#root"));

        //右键菜单事件
        window.oncontextmenu = function(e){
            e.preventDefault();
        }

        window.onkeydown = function(e){
            if(e.keyCode === 67 && e.ctrlKey) {
                e.preventDefault();
            }
        }
    </script>
</body>
</html>